package cn.pn.project.service;

import cn.pn.project.mapper.commodity.SkuDao;
import cn.pn.project.pojo.commodity.Sku;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;
import java.util.List;

@RestController
public class SkuService {
    @Autowired
    SkuDao skuDao;
    /**
     * 根据商品id查询场次id
     * @param commdityId
     * @return
     * @throws SQLException
     */
    @RequestMapping(value = "/getSkuByCommdityId", method = RequestMethod.POST)
    public List<Sku> getSkuByCommdityId(@RequestParam("commdityId")Integer commdityId) throws SQLException{
        System.out.println("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
        return skuDao.getSkuByCommdityId(commdityId);
    }

    @RequestMapping(value = "/getSkuByCommdityIdAndSessionId",method = RequestMethod.POST)
    public List<Sku> getSkuByCommdityIdAndSessionId(@RequestParam(value = "commdityId",required = false)Integer commdityId,@RequestParam("sessionId") Integer sessionId) throws SQLException{
        System.out.println("kjkjkjkjkjkjkjkjkjs");
        System.out.println( skuDao.getSkuByCommdityIdAndSessionId(commdityId,sessionId).size()+"    --------------");
        return  skuDao.getSkuByCommdityIdAndSessionId(commdityId,sessionId);
    }

    /**
     * 常辉辉用
     * @param commdityId
     * @param sessionId
     * @param ticketFileId
     * @return
     * @throws SQLException
     */
    @RequestMapping(value = "/getPrice",method = RequestMethod.POST)
    public Sku getPrice(@RequestParam("commdityId") Integer commdityId,@RequestParam("sessionId") Integer sessionId,@RequestParam("ticketFileId") Integer ticketFileId) throws  SQLException{
        return  skuDao.getPrice(commdityId,sessionId,ticketFileId);
    }
}
